package edu.iss.demo.web.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import edu.iss.demo.model.Employee;
import edu.iss.demo.model.LeaveApplication;
import edu.iss.demo.service.LeaveApplicationService;

@Controller
public class reportController {
	
	@Autowired
	LeaveApplicationService leaveAppService;
	
	@RequestMapping(value={"/manager/report"}, method=RequestMethod.GET)
	public ModelAndView generateReportByManager(HttpServletRequest r)
	{
		Employee e = (Employee) r.getSession().getAttribute("loggedEmployee");
		
		ModelAndView mav = new ModelAndView("m_reports");
		List<LeaveApplication> leaveApplicationList = leaveAppService.findEmployeeList(e.getEmployeeId());
		//List<LeaveApplication> leaveApplicationList = leaveAppService.findAll();
		mav.addObject("leaveApplicationList", leaveApplicationList);
		return mav;
	}
}
